package com.betterjr.modules.risk.loan.util;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONObject;
import com.betterjr.modules.risk.loan.field.ConfigFieldCollections;

public class HttpRequestObject implements Serializable {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = -7332557285429147713L;

    private String url;

    private String paramObject;

    private String requestType;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getParamObject() {
        return paramObject;
    }

    public void setParamObject(String paramObject) {
        this.paramObject = paramObject;
    }

    public String getRequestType() {
        return requestType;
    }

    public void setRequestType(String requestType) {
        this.requestType = requestType;
    }

    @Override
    public String toString() {
        return "HttpRequestObject [url=" + url + ", paramObject=" + paramObject + ", requestType=" + requestType + "]";
    }

    /**
     * 
     * @Title: authronizedUrl 
     * @Description:如果是认证地址返回true    如果不是认证地址则返回false
     * @return TODO(说明)
     * @throws 
     * @author xuyp
     * @date 2018年7月5日 下午1:39:41
     */
    public boolean authronizedUrl() {

        if (this != null && StringUtils.isNoneBlank(this.getUrl())) {

            Field[] fields = ConfigFieldCollections.class.getDeclaredFields();

            for (Field field : fields) {

                try {
                    Object object = field
                            .get(ConfigFieldCollections.class.getDeclaredConstructor(null).newInstance(null));
                    // System.out.println("...." + object);
                    if (object != null) {

                        if (this.getUrl().contains(object.toString())) {
                            return true;
                        }
                    }
                }
                catch (IllegalArgumentException | IllegalAccessException | InstantiationException
                        | InvocationTargetException | NoSuchMethodException | SecurityException e) {
                    e.printStackTrace();
                }

            }

        }

        return false;
    }

}
